<template>
	<view class="uni-calendar-item__weeks-box" :class="{
		'uni-calendar-item--disable':weeks.disable,
		'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
		'uni-calendar-item--checked':(calendar.fullDate === weeks.fullDate && !weeks.isDay) ,
		'uni-calendar-item--before-checked':weeks.beforeMultiple,
		'uni-calendar-item--multiple': weeks.multiple,
		'uni-calendar-item--after-checked':weeks.afterMultiple,
		}" @click="choiceDate(weeks)">
		<view class="uni-calendar-item__weeks-box-item" :class="{

    }">

			<text class="uni-calendar-item__weeks-box-text" :class="{
				'uni-calendar-item--isDay-text': weeks.isDay,
				'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
				'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
				'uni-calendar-item--before-checked':weeks.beforeMultiple,
				'uni-calendar-item--multiple': weeks.multiple,
				'uni-calendar-item--after-checked':weeks.afterMultiple,
				'uni-calendar-item--disable':weeks.disable,
				}">{{weeks.date}}</text>
			<!-- 不展示农历时 今天 -->
			<text v-if="!lunar&&!weeks.extraInfo && weeks.isDay" class="uni-calendar-item__weeks-lunar-text" :class="{
				'uni-calendar-item--isDay-text':weeks.isDay,
				'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
				'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
				'uni-calendar-item--before-checked':weeks.beforeMultiple,
				'uni-calendar-item--multiple': weeks.multiple,
				'uni-calendar-item--after-checked':weeks.afterMultiple,
				}" :style="{
          fontSize: weeks.extraInfo?.text?.size ? `${weeks.extraInfo?.text?.size}px` : '',
          color: weeks.extraInfo?.text?.color || ''
        }">{{todayText}}</text>
			<!-- 展示农历时 今天-->
			<text v-if="lunar" class="uni-calendar-item__weeks-lunar-text" :class="{
            'uni-calendar-item--isDay-text':weeks.isDay,
            'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
            'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
            'uni-calendar-item--before-checked':weeks.beforeMultiple,
            'uni-calendar-item--multiple': weeks.multiple,
            'uni-calendar-item--after-checked':weeks.afterMultiple,
            'uni-calendar-item--disable':weeks.disable,
          }">{{weeks.isDay ? todayText : (weeks.lunar.IDayCn === '初一'?weeks.lunar.IMonthCn:weeks.lunar.IDayCn)}}</text>
		</view>

		<!--    <text
      v-if="weeks.extraInfo&&weeks.extraInfo.info"
      class="uni-calendar-item__weeks-lunar-text"
      :class="{
        'uni-calendar-item--extra':weeks.extraInfo.info,
        'uni-calendar-item--isDay-text':weeks.isDay,
        'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
        'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate ,
        'uni-calendar-item--before-checked':weeks.beforeMultiple,
        'uni-calendar-item--multiple': weeks.multiple,
        'uni-calendar-item--after-checked':weeks.afterMultiple,
        'uni-calendar-item--disable':weeks.disable,
      }"

    >{{weeks.extraInfo.info}}</text> -->
	</view>
</template>

<script>
	import {
		initVueI18n
	} from '@dcloudio/uni-i18n'
	import i18nMessages from './i18n/index.js'
	const {
		t
	} = initVueI18n(i18nMessages)

	export default {
		emits: ['change'],
		props: {
			weeks: {
				type: Object,
				default () {
					return {}
				}
			},
			calendar: {
				type: Object,
				default: () => {
					return {}
				}
			},

			//是否展示农历
			lunar: {
				type: Boolean,
				default: false
			}
		},
		computed: {
			todayText() {
				return t("uni-calender.today")
			},
		},
		methods: {
			choiceDate(weeks) {
				this.$emit('change', weeks)
			}
		}
	}
</script>

<style lang="scss" scoped>
	$uni-font-size-base: 32rpx;
	$uni-text-color: #000;
	$uni-font-size-sm: 12px;
	$uni-color-error: #e43d33;
	$uni-opacity-disabled: 0.3;
	$uni-text-color-disable: #c0c0c0;
	$uni-primary: #54B9CC !default;

	.uni-calendar-item__weeks-box {
		flex: 1;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-top: 10rpx;
	}

	//公历
	.uni-calendar-item__weeks-box-text {
		font-size: $uni-font-size-base;
		color: $uni-text-color;
	}

	//农历样式
	.uni-calendar-item__weeks-lunar-text {
		font-size: $uni-font-size-sm;
		margin-top: 4rpx;
		color: #555;
	}

	.uni-calendar-item__weeks-box-item {
		position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		width: 100rpx;
		height: 100rpx;
	}

	.uni-calendar-item__weeks-box-circle {
		position: absolute;
		width: 8px;
		height: 8px;
		border-radius: 8px;
		background-color: $uni-color-error;

		&:not([position]) {
			top: 2px;
			right: 5px;
		}

		&[position="1"],
		&[position="2"],
		&[position="5"] {
			top: 2px;
		}

		&[position="2"],
		&[position="3"] {
			right: 5px;
		}

		&[position="1"],
		&[position="4"] {
			left: 5px;
		}

		&[position="3"],
		&[position="4"],
		&[position="6"] {
			bottom: 2px;
		}
	}

	.uni-calendar-item--disable {
		background-color: rgba(249, 249, 249, $uni-opacity-disabled);
		color: $uni-text-color-disable;
	}

	.uni-calendar-item--isDay-text {
		color: $uni-primary;
		font-weight: bold;
	}

	.uni-calendar-item--isDay {
		background-color: $uni-primary;
		color: #fff;
	}

	.uni-calendar-item--extra {
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 22rpx;
		color: rgba(28, 37, 58, 0.85);
		width: 94rpx;
		height: 44rpx;
		background: rgba(84, 185, 204, 0.15);
		border-radius: 4rpx 4rpx 4rpx 4rpx;
		line-height: 44rpx;
		text-align: center;
		font-style: normal;
		text-transform: none;
		opacity: 0.8;
	}

	//选中样式
	.uni-calendar-item--checked {
		background-color: $uni-primary;
		color: #fff;
		opacity: 0.8;
	}

	.uni-calendar-item--multiple {
		background-color: $uni-primary;
		color: #fff;
		opacity: 0.8;
	}

	.uni-calendar-item--before-checked {
		background-color: #ff5a5f;
		color: #fff;
	}

	.uni-calendar-item--after-checked {
		background-color: #ff5a5f;
		color: #fff;
	}
</style>